package com.mmt.luolai.ws;

import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.util.Properties;

public class ServiceFactory
{
  public static MymytiServiceServiceSoapBindingStub getMymytiServiceService()
    throws IOException
  {
    Properties props = new Properties();
    String tmpurl = "";
    InputStream wsin = null;
    try {
      wsin = new BufferedInputStream(ServiceFactory.class.getResourceAsStream("/webservice.properties"));
      props.load(wsin);
      tmpurl = props.getProperty("wsAddr");
      System.out.println(tmpurl);
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    MymytiServiceServiceLocator sl = new MymytiServiceServiceLocator();

    MymytiServiceServiceSoapBindingStub myservices = new MymytiServiceServiceSoapBindingStub(
      new URL(tmpurl), sl);
    return myservices;
  }

  public static MymytiServiceServiceSoapBindingStub getMymytiServiceService(String Url)
    throws IOException
  {
    MymytiServiceServiceLocator sl = new MymytiServiceServiceLocator();

    MymytiServiceServiceSoapBindingStub myservices = new MymytiServiceServiceSoapBindingStub(
      new URL(Url), sl);

    return myservices;
  }

  public static MymytiServiceServiceSoapBindingStub getMymytiService(String Url) throws IOException
  {
    MymytiServiceServiceLocator sl = new MymytiServiceServiceLocator();

    MymytiServiceServiceSoapBindingStub myservices = new MymytiServiceServiceSoapBindingStub(new URL(Url), sl);

    return myservices;
  }
}